package com.walter.springai.tools;

import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.model.ToolContext;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.ai.tool.annotation.ToolParam;

import java.util.Date;

/**
 * 获取当前时间
 */
@Slf4j
public class TimeTool {

    @Tool(name = "getTime", description = "获取当前时间")
    public String getTime(@ToolParam(required = false) ToolContext toolContext) {
        log.info("toolContext: {}", toolContext.getContext());
        String format = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
        log.info("当前时间时: {}", format);
        return format;
    }
}
